package tests

import (
	"github.com/gin-gonic/gin"
	"github.com/henrylee2cn/ameda"
	"github.com/henrylee2cn/goutil"
	"my_gin/utils"
	"net/http"
)

// RandString 返回一串随机字符串
func RandString(c *gin.Context) {
	l := c.DefaultQuery("l", "8")
	len, err := ameda.Atoi(l)
	if err != nil {
		len = 8
	}
	rand := goutil.NewRandom(utils.AlphaNum2)
	c.JSON(http.StatusOK, utils.GetApiResponseOK(gin.H{
		"rand_string": rand.RandomString(len),
	}))
}
